<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class CreateQhUserHasCourseTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('qh_user_has_course', function (Blueprint $table) {
            $table->id();
            $table->integer('sourceId', false, true)->nullable()->comment('来源ID，激活码|订单');
            $table->integer('userId', false, true)->comment('用户ID');
            $table->integer('courseId', false, true)->comment('学科ID');
            $table->tinyInteger('type', false, true)->nullable()->comment('来源，1：直接购买，2：激活码兑换');
            $table->timestamps();
        });

        DB::statement("ALTER TABLE qh_user_has_course comment '用户拥有的学科'");
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('qh_user_has_course');
    }
}
